﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ReconCaracteres_Backpropagation
{

    class MyReadFile
    {

        public StreamReader reader;

        public MyReadFile(String fileName){
            reader = new StreamReader(fileName);
        }
        public Sample read()
        {
      
            String line = "";
            String[] values = null;
            Double[,] matrix = new Double[10, 10];
            int categoryIndex = -1;
            int rowCounter = 0;
            if((line = reader.ReadLine())==null){
                return null;
            }
            categoryIndex = Int32.Parse(line.Substring(1, 1));
            while (  rowCounter<10)
            {
                line = reader.ReadLine();
                values = line.Split(' ');
                for (int i = 0; i < values.Count(); i++)
                {
                    matrix[i,rowCounter ] = Double.Parse(values[i]);
     
                }
                rowCounter++;
            }
            Sample sampleRead = new Sample(matrix,categoryIndex);
            return sampleRead;

        }
        public void close(){
            this.close();
        }

    }
}
